package com.lcx.thread.bean;

import java.io.Serializable;

public class LockObj implements Serializable {

    private boolean lock = false;

    public boolean isLock() {
        return lock;
    }

    public void setLock(boolean lock) {
        this.lock = lock;
    }

    public void lock(){
        this.lock=true;
        synchronized (this){
            while(this.isLock()){
                try {
                    this.wait();
                } catch (InterruptedException e) {
                }
            }
        }
    }

    public void unLock(){
        this.lock=false;
        synchronized (this){
            this.notifyAll();
        }
    }
}
